/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.una.informatica.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MARTINCHO
 */
@Entity
@Table(name = "diagnostico_paciente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DiagnosticoPaciente.findAll", query = "SELECT d FROM DiagnosticoPaciente d"),
    @NamedQuery(name = "DiagnosticoPaciente.findByIdPacienteDiagnostico", query = "SELECT d FROM DiagnosticoPaciente d WHERE d.idPacienteDiagnostico = :idPacienteDiagnostico")})
public class DiagnosticoPaciente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_paciente_diagnostico")
    private Long idPacienteDiagnostico;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPacienteDiagnostico")
    private Collection<Reglas> reglasCollection;
    @JoinColumn(name = "id_paciente", referencedColumnName = "id_paciente")
    @ManyToOne(optional = false)
    private Paciente idPaciente;
    @JoinColumn(name = "id_diagnostico", referencedColumnName = "id_diagnostico")
    @ManyToOne(optional = false)
    private Diagnostico idDiagnostico;

    public DiagnosticoPaciente() {
    }

    public DiagnosticoPaciente(Long idPacienteDiagnostico) {
        this.idPacienteDiagnostico = idPacienteDiagnostico;
    }

    public Long getIdPacienteDiagnostico() {
        return idPacienteDiagnostico;
    }

    public void setIdPacienteDiagnostico(Long idPacienteDiagnostico) {
        this.idPacienteDiagnostico = idPacienteDiagnostico;
    }

    @XmlTransient
    public Collection<Reglas> getReglasCollection() {
        return reglasCollection;
    }

    public void setReglasCollection(Collection<Reglas> reglasCollection) {
        this.reglasCollection = reglasCollection;
    }

    public Paciente getIdPaciente() {
        return idPaciente;
    }

    public void setIdPaciente(Paciente idPaciente) {
        this.idPaciente = idPaciente;
    }

    public Diagnostico getIdDiagnostico() {
        return idDiagnostico;
    }

    public void setIdDiagnostico(Diagnostico idDiagnostico) {
        this.idDiagnostico = idDiagnostico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPacienteDiagnostico != null ? idPacienteDiagnostico.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DiagnosticoPaciente)) {
            return false;
        }
        DiagnosticoPaciente other = (DiagnosticoPaciente) object;
        if ((this.idPacienteDiagnostico == null && other.idPacienteDiagnostico != null) || (this.idPacienteDiagnostico != null && !this.idPacienteDiagnostico.equals(other.idPacienteDiagnostico))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.informatica.entidades.DiagnosticoPaciente[ idPacienteDiagnostico=" + idPacienteDiagnostico + " ]";
    }
    
}
